package com.aiwiown.thymleaf.dialect;

import com.aiwiown.thymleaf.dialect.processor.UnEscapeHtml4Processor;
import org.thymeleaf.dialect.AbstractProcessorDialect;
import org.thymeleaf.processor.IProcessor;
import org.thymeleaf.standard.StandardDialect;
import org.thymeleaf.standard.processor.StandardXmlNsTagProcessor;
import org.thymeleaf.templatemode.TemplateMode;

import java.util.HashSet;
import java.util.Set;

/**
 * Thymeleaf 方言：系统用
 * <p>Title: UnEscapeHtml4</p>
 * <p>Description: </p>
 *
 * @author dbin0123
 * @version 1.0.0
 * @date 2019/10/25 10:52
 */
public class UnEscapeHtml4 extends AbstractProcessorDialect {


    /**
     * 前缀
     */
    private static final String PREFIX = "aiwiown";
    /**
     * 定义方言名称
     */
    private static final String NAME = "aiwiown unescapehtml4";


    public UnEscapeHtml4() {
        /**设置自定义方言与“方言处理器”优先级相同*/
        super(NAME, PREFIX, StandardDialect.PROCESSOR_PRECEDENCE);
    }

    /**
     * 元素处理器
     *
     * @param dialectPrefix 方言前缀
     * @return
     */
    @Override
    public Set<IProcessor> getProcessors(String dialectPrefix) {
        Set<IProcessor> processors = new HashSet<IProcessor>();
        /**添加自定义标签*/
        processors.add(new UnEscapeHtml4Processor(dialectPrefix));
        processors.add(new StandardXmlNsTagProcessor(TemplateMode.HTML, dialectPrefix));
        return processors;
    }

}